
# 1、日志中应用装饰器

from functools import wraps

def logit(func):

    @wraps(func)
    def with_logging(*args, **kwargs):
        print(func.__name__ + " was called")
        return func(*args, **kwargs)

    return with_logging

@logit
def addition_func(x):
    """Do some math."""
    return x + x

result = addition_func(5)
print(result)

# Output: addition_func was called